/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package es.unavarra.mti.iws.model;

import es.unavarra.mti.iws.logic.editor.Selectable;
import es.unavarra.mti.iws.logic.properties.HasProperties;
import es.unavarra.mti.iws.logic.properties.KProperty;
import es.unavarra.mti.iws.utils.ReflectionUtils;
import java.util.List;
import java.util.UUID;

/**
 *
 * @author Marcelo
 */
public class Node extends Object2D implements Selectable{
    public static final int TYPE_IRIS = 1;
    public static final int TYPE_IMOTE = 2;

    private UUID id;
    private int type;
    private boolean hasFire,hasRain,hasQuake;
    private float fire,rain,quake;

    public Node() {
        id = UUID.randomUUID();
        type = TYPE_IRIS;
    }

    public float getFire() {
        return fire;
    }

    public void setFire(float fire) {
        this.fire = fire;
    }

    public float getQuake() {
        return quake;
    }

    public void setQuake(float quake) {
        this.quake = quake;
    }

    public float getRain() {
        return rain;
    }

    public void setRain(float rain) {
        this.rain = rain;
    }

   

    public String getId() {
        return id.toString();
    }

    public void setId(String id) {
        this.id = UUID.fromString(id);
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public boolean isHasFire() {
        return hasFire;
    }

    public void setHasFire(boolean hasFire) {
        this.hasFire = hasFire;
    }

    public boolean isHasQuake() {
        return hasQuake;
    }

    public void setHasQuake(boolean hasQuake) {
        this.hasQuake = hasQuake;
    }

    public boolean isHasRain() {
        return hasRain;
    }

    public void setHasRain(boolean hasRain) {
        this.hasRain = hasRain;
    }

    public void setPosition(float x, float y) {
        setX(x); setY(y);
    }

    public float getSizeX() {
        if (type == TYPE_IMOTE){
            return 50;
        }else if (type == TYPE_IRIS){
            return 40;
        }
        return 10.0f;
    }

    public float getSizeY() {
        if (type == TYPE_IMOTE){
            return 50;
        }else if (type == TYPE_IRIS){
            return 40;
        }
        return 10.0f;
    }


    @Override
    public List<KProperty> objectProperties() {
        List<KProperty> prop = super.objectProperties();
        insertMyProperties(prop);
        return prop;
    }


    @Override
    public List<KProperty> objectProperties(Class<? extends HasProperties> c) {
        if (Node.class.isAssignableFrom( c )){
            List<KProperty> prop = super.objectProperties();
            insertMyProperties(prop);
            return prop;
        }
        return super.objectProperties(c);
    }

    private void insertMyProperties(List<KProperty> prop) {
        prop.add(ReflectionUtils.createProperty(Node.class, "type").setName("tipo"));
        prop.add(ReflectionUtils.createProperty(Node.class, "fire").setName("fuego"));
        prop.add(ReflectionUtils.createProperty(Node.class, "rain").setName("lluvia"));
        prop.add(ReflectionUtils.createProperty(Node.class, "quake").setName("terremoto"));
    }

}
